//
//  UIButton+extension.swift
//  PandaEye_Weibo
//
//  Created by Xuan Zhang on 16/6/14.
//  Copyright © 2016年 Xuan Zhang. All rights reserved.
//

import UIKit
extension UIButton{
    convenience init(title:String,
        titleColor:UIColor = UIColor.darkGrayColor(),
        font:CGFloat = 12,
        image:String?=nil,
        backgroundImage:String?=nil,
        target:AnyObject?=nil,
        action:String?=nil,
        event:UIControlEvents = .TouchUpInside){
        self.init()
        setTitle(title, forState: .Normal)
        setTitleColor(titleColor, forState: .Normal)
        if let image = image{
            setImage(UIImage(named: image), forState: .Normal)
            setImage(UIImage(named: image+"_highlighted"), forState: .Highlighted)
        }
        if let backgroundImage = backgroundImage{
            setBackgroundImage(UIImage(named: backgroundImage), forState: .Normal)
            setBackgroundImage(UIImage(named: backgroundImage+"_highlighted"), forState: .Highlighted)
        }
//         let selector = Selector(action!)
//         addTarget(target, action: selector, forControlEvents: event)
    }
}